import sys
import math
from decimal import *
def prime_generator(nr_elemente_prime):
vector_prime=[-1]*nr_elemente_prime
vector_rasp=[0]*nr_elemente_prime
vector_prime[1]=1
vector_rasp[1]=1
contor=2
for i in range(2,nr_elemente_prime):
if vector_prime[i]==-1:
vector_prime[i]=1
vector_rasp[contor]=i
contor=contor+1
for j in range(i+i,nr_elemente_prime,i):
if vector_prime[j]==-1:
vector_prime[j]=i
set_prime=set(vector_rasp)
sume_disponibile=set()
for i in range(3,nr_elemente_prime):
sume_disponibile.add(vector_rasp[i-1]+vector_rasp[i])
rasp_final=""
def transformare_baza(numar,baza):
transformare=""
while numar>=baza:
rest=numar%baza
numar=numar//baza
transformare+=str(rest)
transformare+=str(numar)
noua_baza=transformare[::-1]
return noua_baza
def bitwise_xor(a,b):
stringul_1=transformare_baza(a,2)
stringul_2=transformare_baza(b,2)
lungime=max(len(stringul_1), len(stringul_2))
raspunsul=0
str_answ=[0]*lungime
for i in range(0,lungime):
j=lungime-1-i
if len(stringul_1)>i and len(stringul_2)>i:
if stringul_1[len(stringul_1)-1-i]!= stringul_2[len(stringul_2)-1-i]:
raspunsul+=2**(i)
str_answ[i]='1'
elif len(stringul_1)>i and stringul_1[len(stringul_1)-1-i]=='1':
raspunsul+=2**(i)
str_answ[i]='1'
elif len(stringul_2)>i and stringul_2[len(stringul_2)-1-i]=='1':
raspunsul+=2**(i)
str_answ[i]='1'
return raspunsul
def bitwise_or(a,b):
stringul_1=transformare_baza(a,2)
stringul_2=transformare_baza(b,2)
lungime=max(len(stringul_1), len(stringul_2))
raspunsul=0
str_answ=[0]*lungime
for i in range(0,lungime):
j=lungime-1-i
if len(stringul_1)>i and len(stringul_2)>i:
if stringul_1[len(stringul_1)-1-i]=='1' or stringul_2[len(stringul_2)-1-i]=='1':
raspunsul+=2**(i)
str_answ[i]='1'
elif len(stringul_1)>i and stringul_1[len(stringul_1)-1-i]=='1':
raspunsul+=2**(i)
str_answ[i]='1'
elif len(stringul_2)>i and stringul_2[len(stringul_2)-1-i]=='1':
raspunsul+=2**(i)
str_answ[i]='1'
return raspunsul
def cmmdc(x,y):
maximul=max(x,y)
minimul=min(x,y)
while maximul!=minimul and minimul!=0:
dif=maximul-minimul
raport=dif//minimul
maximul-=minimul*(raport+1)
a=max(minimul,maximul)
b=min(minimul, maximul)
maximul=a
minimul=b
return (maximul)
dict = {}
alfabet = {'a': 1, 'b': 2,'c': 3,'d': 4,'e': 5,'f': 6,'g': 7,'h': 8,'i': 9,'j': 10,'k': 11,'l': 12,'m': 13,'n': 14,'o': 15,'p': 16,'q': 17,'r': 18,'s': 19,'t': 20,'u': 21,'v': 22,'w': 23,'x': 24,'y': 25,'z': 26}
contor=0
k=1
while k>0:
n=int(input())
suma=0
for i in range(2,n):
numar=n
while numar>=i:
rest=numar%i
numar=numar//i
suma+=rest
suma+=numar
numarator=suma
numitor=n-2
while cmmdc(numarator,numitor)>1:
retur=cmmdc(numarator,numitor)
numarator=numarator/retur
numitor=numitor/retur
print(str(int(numarator))+"/"+str(int(numitor)))
k-=1
//@author aayush_nb
#include <bits/stdc++.h>
using namespace std;
int main(){
int a; cin>>a; int sum=0;
for(int i=2;i<=a-1;i++){
int d=a;
while(d>0){
sum+=d%i;
d/=i;
}
} int n=a-2;
int d=__gcd(sum,n);
sum/=d; n/=d;
cout<<sum<<"/"<<n<<endl;
}
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |
445. Add Two Numbers II | 442. Find All Duplicates in an Array |
437. Path Sum III | 436. Find Right Interval |
435. Non-overlapping Intervals | 406. Queue Reconstruction by Height |
380. Insert Delete GetRandom O(1) | 332. Reconstruct Itinerary |
368. Largest Divisible Subset | 377. Combination Sum IV |
322. Coin Change | 307. Range Sum Query - Mutable |
287. Find the Duplicate Number | 279. Perfect Squares |
275. H-Index II | 274. H-Index |
260. Single Number III | 240. Search a 2D Matrix II |
238. Product of Array Except Self | 229. Majority Element II |
222. Count Complete Tree Nodes | 215. Kth Largest Element in an Array |
198. House Robber | 153. Find Minimum in Rotated Sorted Array |